<template>
	<view class="search_wrap">
		<view class="tn-flex tn-flex-col-center">
			<tn-input v-model="search_value" inputAlign="center" placeholder="搜索商品" />
			<text class="search_title" @click="search">搜索</text>
		</view>
		<view class="history_wrap">
			<History v-if="!is_show" />
			<view v-else>
				<GoodsList />
				<Cart />
			</view>
		</view>
	</view>
</template>

<script>
	import GoodsList from '@/components/goods_list.vue';
	import Cart from '@/components/cart.vue';
	import History from './components/history.vue';
	export default {
		components: {
			GoodsList,
			Cart,
			History
		},
		data() {
			return {
				is_show: false,
				search_value: "",
				history_list: ["土豆土豆土豆土豆土豆", "粉丝", "黄瓜", "白菜", "西红柿", "莲花白", "苦瓜", "莴笋"],
				loadText: {
					loadmore: '下拉加载',
					loading: '快速加载中...',
					nomore: '已经没有了啊'
				}
			}
		},
		methods: {
			handle_width(str) {
				return `${str.length * 30}rpx`
				console.log('str', str.length);
			},
			search() {
				this.is_show = true
			}
		}
	}
</script>

<style scoped lang="scss">
	.cart_wrap {
		position: relative;
		left: 20rpx;
		bottom: 20rpx;
		width: 100rpx;
		height: 100rpx;
		border-radius: 50%;
		background-color: #777;

		.cart_number {
			position: absolute;
			right: 0rpx;
			width: 40rpx;
			height: 40rpx;
			background-color: red;
			color: #fff;
			font-size: 26rpx;
			border-radius: 50%;
			text-align: center;
			line-height: 40rpx;
		}

		.cart {
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%) !important;
		}
	}

	.tag {
		border-radius: 10rpx;
	}

	.history_list {
		margin-top: 30rpx;
	}

	/deep/ .tn-input {
		margin: 10rpx 10rpx 10rpx 20rpx;
		width: 50vw;
		background-color: #eee;
		border-radius: 20px;
	}

	.search_title {
		margin: 0 40rpx;
		font-size: 34rpx;
	}

	.history_wrap {
		padding: 20rpx;

		.history_title {
			font-size: 34rpx;
		}
	}
</style>